
package com.rt.schedulenew.task;

import com.rt.schedulebase.dto.DictExamQueueDto;
import com.rt.schedulebase.dto.ExamApplyDto;
import com.rt.schedulenew.api.ICommonService;
import com.rt.schedulenew.service.impl.CommonServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;

public class GetScheduleDateTask implements Callable<ExamApplyDto> {
    private volatile String date;
    private volatile List<DictExamQueueDto> queues;
    private volatile ExamApplyDto apply;
    private volatile double reqCount;
    private volatile ICommonService commonServiceImpl;

    @Override
    public ExamApplyDto call() {
        List<DictExamQueueDto> list;
        if (StringUtils.isBlank(apply.getIsGreenChannel())) {
            list = commonServiceImpl.getQueueListByDate(queues, date, null);
        } else {
            list = new ArrayList<>(queues);
        }
        if (CollectionUtils.isEmpty(list)) {
            return null;
        }
        // 构建和获取可以预约的日期列表
        ExamApplyDto examApplyDto = commonServiceImpl.getScheduleDate(list, date, apply);
        return examApplyDto;
    }

    public String getDate() {
        return date;
    }

    public List<DictExamQueueDto> getQueues() {
        return queues;
    }

    public ExamApplyDto getApply() {
        return apply;
    }

    public double getReqCount() {
        return reqCount;
    }

    public ICommonService getCommonServiceImpl() {
        return commonServiceImpl;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public void setQueues(List<DictExamQueueDto> queues) {
        this.queues = queues;
    }

    public void setApply(ExamApplyDto apply) {
        this.apply = apply;
    }

    public void setReqCount(double reqCount) {
        this.reqCount = reqCount;
    }

    public void setCommonServiceImpl(ICommonService commonServiceImpl) {
        this.commonServiceImpl = commonServiceImpl;
    }
}
